import {BaseModel} from "../BaseModel";

export class Downloader extends BaseModel{

    constructor(){
        super();
        this.symbolName = "Downloader";
        this.tableName = "t_downloader";
        this.id = '';//主键id,下载任务的taskId,即lessonId
        this.isBook = '';//是不是全书下载：0 - 不是；1 - 是
        this.downloadParam = '';//下载参数
        this.downloaderStatus = '';//下载状态，只记录如下几种状态：0 - 塞入状态；1 - 失败状态；2 - 成功状态
        this.fillTime = '';//加入下载中心的时间
        this.userId = '';//用户id
        this.reverse1 = '';//备用字段1
        this.reverse2 = '';//备用字段2
        this.reverse3 = '';//备用字段3
    }

    dbMapper(){
        return {
            id: 'id',
            isBook: 'is_book',
            downloadParam: 'download_param',
            downloaderStatus: 'downloader_status',
            fillTime: 'fill_time',
            userId: "user_id",
            reverse1: 'reverse1',
            reverse2: 'reverse2',
            reverse3: 'reverse3'
        }
    }

    /**
     * 输出转换
     * @param obj
     * @returns {Book}
     */
    mappingModel(obj){
        let downloader = new Downloader();
        downloader.id = obj.id ? obj.id : ''
        downloader.isBook = obj.is_book ? obj.is_book : ''
        downloader.downloadParam = obj.download_param ? obj.download_param : ''
        downloader.downloaderStatus = obj.downloader_status ? obj.downloader_status : ''
        downloader.fillTime = obj.fill_time ? obj.fill_time : ''
        downloader.userId = obj.user_id ? obj.user_id : ''
        downloader.reverse1 = obj.reverse1 ? obj.reverse1 : ''
        downloader.reverse2 = obj.reverse2 ? obj.reverse2 : ''
        downloader.reverse3 = obj.reverse3 ? obj.reverse3 : ''
        return downloader;
    }
}
